<template>
  <!-- 组织结构 首页 -->
  <el-dialog
    v-el-drag-dialog
    title="组织结构详情"
    :visible.sync="crud.status.info > 0"
    :before-close="crud.closeInfo"
  >
    <div class="info_detail_dialog__body">
      <el-card v-loading="crud.infoLoading" class="box-card" shadow="hover">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">详情ID: </div><div class="info_detail_value">{{ info.id }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">组织名字: </div><div class="info_detail_value">{{ info.depName || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">组织机构代码: </div><div class="info_detail_value">{{ info.depCode || '-' }}</div></el-col>
          <!-- 上级信息 -->
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">父级名字: </div><div class="info_detail_value">{{ info._parentInfo.depName || '-' }}</div></el-col>
          <!-- 组织结构级别 默认都是第一级，每往下一级加1 -->
          <!-- 智能推断为字典类型, 字典类型为 dict.sys_department_level -->
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">组织结构级别: </div><div class="info_detail_value">{{ info.level +' 级' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">组织的logo: </div><div class="info_detail_value">{{ info.logo || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">负责人: </div><div class="info_detail_value">{{ info.principal || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">联系电话: </div><div class="info_detail_value">{{ info.linkPhone || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">省id: </div><div class="info_detail_value">{{ info.provinceId || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">市id: </div><div class="info_detail_value">{{ info.cityId || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">县id: </div><div class="info_detail_value">{{ info.countyId || '-' }}</div></el-col>
          <!-- 县级以上名字 ，中间用-分割 -->
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">县级以上名字: </div><div class="info_detail_value">{{ info.countyName || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">详细地址: </div><div class="info_detail_value">{{ info.depAddress || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">组织描述: </div><div class="info_detail_value">{{ info.description || '-' }}</div></el-col>
          <!-- 状态值，字典取值 -->
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">状态 </div><div class="info_detail_value">{{ dict.label.common_status[info.status] || '未知字典码:'+info.status }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">排序: </div><div class="info_detail_value">{{ info.paixu || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">备注: </div><div class="info_detail_value">{{ info.remark || '-' }}</div></el-col>

          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">创建时间:</div><div class="info_detail_value">{{ info.createTime || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">创建人:</div><div class="info_detail_value">{{ info.createUserName || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">最后一次修改时间:</div><div class="info_detail_value">{{ info.updateTime || '-' }}</div></el-col>
          <el-col :xs="24" :sm="12" :md="8"><div class="info_detail_name">最后一次修改人:</div><div class="info_detail_value">{{ info.updateUserName || '-' }}</div></el-col>

        </el-row>

      </el-card>
    </div>
  </el-dialog>
</template>

<script>
import elDragDialog from '@/directive/el-drag-dialog'
import CRUD, { info } from '@crud/crud'
// 组织结构 - model
const defaultInfo = {
  id: null, // id
  depName: null, // 组织名字
  depCode: null, // 组织机构代码
  parentId: '0',
  _parentInfo: {}, // 父类信息
  parentName: null, // 父级名字
  topId: null, // 顶级组织id
  level: null, // 组织结构级别 默认都是第一级，每往下一级加1
  logo: null, // 组织的logo
  principal: null, // 负责人
  linkPhone: null, // 联系电话
  provinceId: null, // 省id
  cityId: null, // 市id
  countyId: null, // 县id
  countyName: null, // 县级以上名字 ，中间用-分割
  depAddress: null, // 详细地址
  description: null, // 组织描述
  status: 1,
  paixu: 1,
  remark: null, // 备注
  lockVersion: 0,
  createTime: null,
  createUserName: null,
  updateTime: null,
  updateUserName: null,
  isDel: 0

}
export default {
  directives: { elDragDialog },
  mixins: [info(defaultInfo)],
  dicts: [
    'common_status'
  ], // 字典
  data() {
    return {

    }
  },
  mounted() {
  },
  methods: {
    [CRUD.HOOK.afterDoInfo]() {
      if (this.info.parentId && this.info.parentId !== '0') {
        this.crud.crudMethod.info(this.info.parentId).then(res => {
          this.info._parentInfo = res.data
        }).catch((error) => {
          this.crud.notify('未找到上级信息', CRUD.NOTIFICATION_TYPE.ERROR)
          console.log(error)
        })
      }
      return true
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
